<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/12/1
 * Time: 17:57
 */
namespace app\common\helper;

class index_msg_helper
{
    /**
     * 取首页图文信息
     * @param array $params
     * @return array
     */
    public static function get_info($params = array())
    {
        $list = array();
        $info = self::get_index_msg();
        $list[0] = $info;

        return $list;
    }

    /**
     * 取首页图文信息
     * @param int $company_id
     * @param int $open_card_id
     * @return array
     */
    public static function get_index_msg($company_id = 0, $open_card_id = 0)
    {
        if (!$open_card_id) {
            $open_card_id = open_card_helper::get_open_card_id();
        }
        if (!$company_id) {
            $company_id = company_helper::get_company_id();
        }

        $filter = array(
            'company_id'   => $company_id,
            'open_card_id' => $open_card_id
        );

        $info = _uri('index_msg', $filter);
        if (!$info) {
            $info = array(
                'title'    => '欢迎关注',
                'cover'    => SITE_URL.'/images/m/index_default/1.jpg',
                'intro'    => '点击查看官网',
                'type'     => 1,
                'link'     => SITE_URL.'/m.html',
                'add_time' => date('Y-m-d H:i:s')
            );
        }
        if (!isset($info['cover']) || !$info['cover']) {
            $info['cover'] = SITE_URL.'/images/m/index_default/1.jpg';
        }
        if (!isset($info['link']) || !$info['link']) {
            $info['link'] = SITE_URL.'/m.html';
        }

        return $info;
    }


    /**
     * 取首页图文拼装成二维数组
     * @return array
     */
    public static function get_index_msg_list()
    {
        $list = array();
        $info = self::get_index_msg();
        $list[0] = $info;

        return $list;
    }
}